<?php
class CharaccountModel extends Model {
	protected $fields = array(
		'uid',
		'username',
		'password',
		'nicename',
		'email',
		'secquestion',
		'secanswer',
		'money',
		'regtime',
		'lastlogintime',
		'_pk'=>'uid',
		'_autoInc'=>true
	);
	
	protected $_validate     =     array( 
        array('username','require','用户名必须！',1), 
        array('username','','用户名重复！',0,'unique','add'), 
        array('password','require','密码必须！',1), 
        array('password2','password','密码不一致！',0,'confirm'),
        array('email','require','邮箱必须！',1), 
        array('email','email','邮箱格式错误！',2), 
        array('verify','require','验证码必须！'), 
        array('verify','CheckVerify','验证码错误！',0,'callback'), 
        ); 
	
	protected $_auto = array(
		array('regtime','time','add','function'),
		array('lastlogintime','time','add','function'),
		array('lastlogintime','time','save','function'),
		array('password','md5','add','function'),
		array('money','0','ADD'),
		);

	public function CheckVerify() {
		return md5($_POST['verify']) == $_SESSION['verify'];
	}
}
?>